package jobs

import (
	"gitee.com/pangxianfei/framework/kernel/debug"
	"gitee.com/pangxianfei/framework/queue/work"
	"github.com/golang/protobuf/proto"

	"tmaic/app/login/jobs/proto3/protomodel"
)

func init() {
	work.Add(&loginJob{})
}

var LoginJob = new(loginJob)

type loginJob struct {
	work.Job
}

// Retries 失败重启次数
func (e *loginJob) Retries() uint32 {
	return 3
}

// Name 列队名称  Topics 名
func (e *loginJob) Name() string {
	return "login"
}

func (e *loginJob) SetParam(paramPtr proto.Message) {
	e.Job.SetParam(paramPtr)
}

func (e *loginJob) ParamData() proto.Message {
	return e.Job.ParamProto()
}

// ParamProto proto 类名参数 实例
func (e *loginJob) ParamProto() proto.Message {
	return &protomodel.LoginJob{}
}

// Handle 执行
func (e *loginJob) Handle(paramPtr proto.Message) error {
	LoginJobObj := paramPtr.(*protomodel.LoginJob)
	debug.Dd(LoginJobObj)
	return nil
}
